<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        let name = "xuan";
        let age = 18;

        // let person = {
        //     name: name,
        //     age: age,
        //     showname: function () {
        //         alert(this.name);
        //     },
        //     showage: function() {
        //         alert(this.age);
        //     }
        // }

        // 上述简写
        let person = {
            name: name,
            age: age,
            showname () {
                alert(this.name);
            },
            showage () {
                alert(this.age);
            }
        }

        person.showname();
        person.showage();
    </script>
</head>
<body>
    
</body>
</html>